<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>
                <div class="row">
                    <div class="col-sm-22 widget-container-col ui-sortable" id="widget-container-col-10">
                        <div class="widget-box ui-sortable-handle" id="widget-box-10">
                            <div class="widget-header widget-header-small">
                                <h5 class="widget-title smaller">产品信息</h5>
                            </div>

                            <div class="widget-body">
                                <div class="widget-main padding-6" style="overflow: hidden">
                                    <div class="tab-content">
                                        <div id="home" class="tab-pane active">
                                            <div class="col-xs-12">
                                                <!-- PAGE CONTENT BEGINS -->
                                                <form class="form-horizontal" action="<?php echo site_url(X_URL.'goods/update');?>" method="post" id="from1" >
                                                    <?php echo csrf_hidden();?>
                                                    <input type="hidden" name="good_id" value="<?php if(!empty($good_id)){  echo $good_id;}?>">
                                                    <div class="space-4"></div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right" for="form-field-4"> 产品类型 </label>
                                                        <div class="col-sm-9">
                                                            <select id="good_category" name="good_category" class="select2 rcol-xs-10 col-sm-5">
                                                                <option value="0">请选择产品类型</option>

                                                                <?php if(isset($category2) && !empty($category2)){ ?>
                                                                    <?php foreach ($category2 as $key2 =>$val2 ) { ?>
                                                                        <option value="<?php echo $val2['id'];?>" <?php if(isset($good) && $good['good_category'] == $val2['id']){?>selected="selected"<?php } ?>
                                                                        ><?php echo $val2['category_name'];?></option>
                                                                    <?php }?>
                                                                <?php }?>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 产品名称 </label>
                                                        <div class="col-sm-9">
                                                            <input type="text" name="good_title" class="rcol-xs-10 col-sm-5" value="<?php if(isset($good)){ echo $good["good_title"];}?>">
                                                            <input type="hidden" name="good_id" value="<?php if(isset($good)){ echo $good["good_id"];}?>">
                                                            <span class="help-inline col-xs-12 col-sm-7">
                											     <span class="middle">请填写产品名称</span>
                											</span>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right" for="form-field-2"> 产品单价 </label>
                                                        <div class="input-group col-sm-3" style="padding-left: 15px;">
                                                            <input  class="form-control input-mask-product" type="text" name="good_price" id="good_price" value="<?php if(!empty($good['good_price'])){  echo $good['good_price'];}?>"  />
                                                            <span class="input-group-addon">
																	<i class="ace-icon fa fa-rmb"></i>
																</span>
                                                        </div>
                                                    </div>
                                                    <div class="space-4"></div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right" for="form-field-7"> 产品规格 </label>
                                                        <div class="col-sm-9">
                                                            <textarea name="good_memo" id="good_memo" placeholder="产品介绍"  class="col-xs-10 col-sm-10"  rows="5"><?php if(!empty($good['good_memo'])){  echo $good['good_memo'];}?></textarea>
                                                            <span class="help-inline col-xs-12 col-sm-7">
                                                            <span class="middle"></span>
                                                        </span>
                                                        </div>
                                                    </div>
                                                    <div class="space-4"></div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right" for="form-field-8">
                                                            制作工艺 </label>
                                                        <div class="col-sm-9">
                                                            <textarea name="good_content" id="good_content" style="width:85%;height:400px;visibility:hidden;"><?php if(!empty($good['good_content'])){  echo $good['good_content'];}?></textarea>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-offset-2 col-md-9">
                                                        <button class="btn btn-info" type="submit" id="subForm1">
                                                            <i class="icon-ok bigger-110"></i>
                                                            提交
                                                        </button>

                                                        &nbsp; &nbsp; &nbsp;
                                                        <button class="btn" type="reset">
                                                            <i class="icon-undo bigger-110"></i>
                                                            重置
                                                        </button>
                                                    </div>


                                                </form>
                                                <!-- PAGE CONTENT ENDS -->
                                            </div><!-- /.col -->
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /section:settings.box -->
                <div class="row">

                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        var good_id = "<?php if(!empty($good_id)){  echo $good_id;}?>";
        $("#tabs").tabs();
        var editor = KindEditor.create('textarea[name="good_content"]', {
            uploadJson: baseurl+'index.php/manage/pubfun/editor_upload_img?type=shop&shopid=1',
            fileManagerJson: '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function () {
                this.sync();
            }
        });

        $("#subForm1").click(function () {

            var good_title = $("#good_title").val();
            if (good_title == "") {
                bootbox.dialog({
                    title: '友情提示：',
                    message: "商品名称必须填写。",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }
            var good_price = $("#good_price").val();
            if (good_price == "") {
                bootbox.dialog({
                    title: '友情提示：',
                    message: "商品单价必须填写。",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }

            $("#from1").submit();
        });
    });
</script>
</body>
</html>
